<?php
//---------------------------database class-----------------------------------//

class database {

    private $database;
    private $server;
    private $username;
    private $password;

    public function database($database, $server, $username, $password) {
        $this->database = $database;
        $this->server = $server;
        $this->username = $username;
        $this->password = $password;
    }

//End of database constructor

    public function database_connect() {
        $sql_connection = @mysql_connect($this->server, $this->username, $this->password);
        if (!$sql_connection) {
            die("Could not connect to MySQL server!");
        }

        if (!mysql_select_db($this->database)) {
            $this->database_query("CREATE DATABASE " . $this->database, "Unable to create database:");

            if (!mysql_select_db($this->database)) {
                die("Database creation error: " . mysql_error());
            }
        }
    }

//End of database_connect function

    public function database_query($query, $error_info) {
        $mysql_query = mysql_query($query);
        if (!mysql_query) {
            return false; //return false if query error.
            die($error_info . " " . mysql_error() . "<br>");
        }
        return $mysql_query;
    }

//End of database_query function

    public function database_fetch_array($query_result) {
        return mysql_fetch_array($query_result);
    }

//End of database_fetch_array function

    public function database_fetch_assoc($query_result) {
        return mysql_fetch_assoc($query_result);
    }

//End of database_fetch_assoc function

    public function database_query_num_rows($query_result) {
        return mysql_num_rows($query_result);
    }

//End of database_query_num_rows function

    public function database_table_drop($table) {
        return $this->database_query("DROP TABLE $table", "Table drop error");
    }

//End of database_table_drop
}

//End of Database Class
?>
